//
//  TextUpperLeftLabel.swift
//  自适应label
//
//  Created by apple on 2018/8/13.
//  Copyright © 2018年 rtb.jiyong.com. All rights reserved.
//  label 文字从左上角开始

import UIKit

class TextUpperLeftLabel: UILabel {
    
    override func textRect(forBounds bounds: CGRect, limitedToNumberOfLines numberOfLines: Int) -> CGRect {
        var textRect = super.textRect(forBounds: bounds, limitedToNumberOfLines: numberOfLines)
        textRect.origin.y = bounds.origin.y
        return textRect
    }
    
    override func drawText(in rect: CGRect) {
        let actualRect = self.textRect(forBounds: rect, limitedToNumberOfLines: self.numberOfLines)
        super.drawText(in: actualRect)
    }

}

